# Maintainer: Jaroslav Lichtblau <svetlemodry@archlinux.org>
# Contributor: Alois Nespor <alois.nespor@gmail.com>

pkgbase=kid3
pkgname=('kid3-common' 'kid3-qt' 'kid3')
pkgver=3.9.4
pkgrel=2
pkgdesc="An MP3, Ogg/Vorbis and FLAC tag editor"
arch=('loong64' 'x86_64')
url="https://kid3.kde.org/"
license=('GPL')
depends=('chromaprint' 'flac' 'id3lib' 'kxmlgui5' 'libmp4v2'
         'qt5-declarative' 'qt5-multimedia' 'taglib' 'kio5')
makedepends=('cmake' 'docbook-xsl' 'extra-cmake-modules' 'kdoctools5' 'python' 'qt5-tools')
changelog=$pkgbase.changelog
source=(https://prdownloads.sourceforge.net/$pkgbase/$pkgbase-$pkgver.tar.gz{,.sig})
validpgpkeys=('7D09794C2812F62194B081C14CAD34426E354DD2') # Urs Fleisch
sha256sums=('6d67d941604c3d96e42b2bafbe7ec4a60004620b729ccbe2550af211eb59dd7b'
            'SKIP')

build() {
  export CXXFLAGS+=' -DNDEBUG' # FS#69904
  cmake -B build -S ${pkgbase}-${pkgver} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DWITH_APPS="CLI;Qt;KDE" \
    -DWITH_MP4V2=ON \
    -DWITH_FFMPEG=ON \
    -DWITH_GSTREAMER=ON \
    -Wno-dev
  cmake --build build
}

package_kid3-common() {
  pkgdesc="An MP3, Ogg/Vorbis and FLAC tag editor, CLI version and common files"
  depends=('chromaprint' 'flac' 'id3lib' 'libmp4v2' 'libvorbis' 'qt5-base' 'taglib')
  optdepends=('qt5-declarative: GUI support library'
              'qt5-multimedia: GUI support library')

  make -C build DESTDIR="${pkgdir}" install

  rm -r "$pkgdir"/usr/bin/kid3{,-qt} \
        "$pkgdir"/usr/share/{applications,icons,kxmlgui5,metainfo}
}

package_kid3-qt() {
  pkgdesc="An MP3, Ogg/Vorbis and FLAC tag editor, Qt version"
  depends=("kid3-common=$pkgver" 'qt5-declarative' 'qt5-multimedia')

  make -C build/src/app/qt DESTDIR="${pkgdir}" install
}

package_kid3() {
  pkgdesc="An MP3, Ogg/Vorbis and FLAC tag editor, KDE version"
  depends=("kid3-common=$pkgver" 'kxmlgui5' 'qt5-declarative' 'qt5-multimedia' 'kio5')

  make -C build/src/app DESTDIR="${pkgdir}" install

  rm -r "$pkgdir"/usr/bin/kid3-{cli,qt} \
        "$pkgdir"/usr/share/applications/org.kde.kid3-qt.desktop \
        "$pkgdir"/usr/share/icons/hicolor/*/apps/kid3-qt.{png,svg} \
        "$pkgdir"/usr/share/metainfo/org.kde.kid3-qt.appdata.xml
}
